/********************************************************************************************************************
** Contact: yashvpatil@gmail.com
**
** GNU General Public License Usage
** This file may be used under the terms of the GNU
** General Public License versions 2.0 or 3.0 as published by the Free Software Foundation.
** Please review the following information to ensure GNU General Public Licensing requirements will be met:
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
*********************************************************************************************************************/

#ifndef _QRANGEWIDGET_H_
#define _QRANGEWIDGET_H_

#include <QtGui>

#include "qrangewidget_common.h"

//! Base Class for defining various types of range widgets
/*!
The QRangeWidget class provides an easy approach to display ranges like signal strength, battery level etc. Inherits QWidget\n\n

The class is a pure virtual class with pure virtual method drawTowers(). The drawing logic shall be implemented in derived implementation of drawTowers()\n\n

The class has following attributes \n
1. Level: Defines six different level from NORANGE to OUTSTANDING\n
2. Orientation: Defines the direction in which range towers shall be painted on screen.\n

The slot setLevel() is provided to set level of range.\n\n

Following orientations are available\n
a. HORIZONTAL: Draws towers from left to right\n
b. VERTICAL: Draws towers from top to bottom\n
c. HORIZONTAL_R: Draws towers from right to left\n
d. VERTICAL_R: Draws towers from bottom to top\n\n

The method setOrientation() is provided to set orientation.\n\n

The method setForeColor() is provided to set foreground color of range towers\n\n

The method setBackColor() is provided to set background color of range towers\n\n
*/
class QRANGEWIDGETSHARED_EXPORT QRangeWidget:public QWidget
{
	Q_OBJECT
public:

//! An enum.
/*! Defines different levels of range */
	enum Level {
				NORANGE = 0, /*!< Value describing no range. */
				POOR,        /*!< Value describing poor range. */
				LOW,         /*!< Value describing low range. */
				GOOD,        /*!< Value describing good range. */
				EXCELLENT,   /*!< Value describing excellent range. */
				OUTSTANDING  /*!< Value describing outstanding range. */
				};

//! An enum.
/*! Defines different orientations */
	enum Orientation {
						HORIZONTAL = 0, /*!< Value describing left to right orientation. */
						VERTICAL,       /*!< Value describing top to bottom orientation. */
						HORIZONTAL_R,   /*!< Value describing right to left orientation. */
						VERTICAL_R      /*!< Value describing bottom to top orientation. */
						};

//! A constructor.
/*!
  Constructs a new range widget.

 \param x is an integer argument describing X position of range widget
 \param y is an integer argument describing Y position of range widget
 \param parent is a QWidget describing parent widget
*/
	QRangeWidget(int x, int y, QWidget *parent);

//! Destructor.
/*!
Destructor.
*/
	virtual ~QRangeWidget();

//! A normal member taking one argument and returning nothing.
/*!
   This function used to set back color of range widget
  \param color A QColor argument specifying fore color
  \sa setBackColor()
*/
	void setForeColor(QColor color);

//! A normal member taking one argument and returning nothing.
/*!
   This function used to set forecolor of range widget
  \param color A QColor argument specifying back color
  \sa setForeColor()
*/
	void setBackColor(QColor color);

//! A normal member taking one argument and returning nothing.
/*!
   This function used to set orientation of range widget
  \param o Argument specifying range orientation
  \sa Orientation
*/
	void setOrientation(Orientation o);

//! A normal member taking one argument and returning nothing.
/*!
   This function used to set width of pen used to paint widget
  \param w Argument specifying width of pen used for drawing
*/
	void setPenWidth(int w);

//! A normal member taking one argument and returning current level of range
/*!
   This function used to read current level of range widget
  \param s Argument specifying string for storing text describing level
  \return Current level of range widget
*/
	QRangeWidget::Level currentRange(QString &s);

public slots:
//! A slot taking one argument and returning nothing.
/*!
   This function used to set level of range widget
  \param l Argument specifying level of range to be set
*/
	void setLevel(Level l);

//! A pure virtual member.
/*!
  \param painter For painting towers on widget
*/
	virtual void drawTowers(QPainter & painter) = 0;

protected:

//! A protected member.
/*!
*/
	void paintEvent(QPaintEvent *);

//! A protected variable.
/*!
  Specifies current level of range widget
*/
	Level value;

//! A protected variable.
/*!
  Specifies current orientation of range widget
*/
	Orientation orientation;

private:
//! A private variable.
/*!
  Specifies pen used for drawing operations
*/
	QPen pen;
};


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


//! Class derived from QRangeWidget for defining range widget drawing range towers in bar form
/*!
The QRangeWidget_Bar class provides an easy approach to display ranges like signal strength, battery level etc in bar form. Inherits QRangeWidget\n\n
*/
class QRANGEWIDGETSHARED_EXPORT QRangeWidget_Bar:public QRangeWidget
{
	Q_OBJECT
public:
//! A constructor.
/*!
  Constructs a new QRangeWidget_Bar widget.

 \param x is an integer argument describing X position of range widget
 \param y is an integer argument describing Y position of range widget
 \param parent is a QWidget describing parent widget
*/
	QRangeWidget_Bar(int x, int y, QWidget *parent);

//! Destructor.
/*!
Destructor.
*/
	virtual ~QRangeWidget_Bar();

//! A derived member taking one argument and returning nothing
/*!
   This function used to implement drawing logic
  \param painter Argument specifying painter to be used for drawing bar ranges
*/
	void drawTowers(QPainter & painter);

};


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


//! Class derived from QRangeWidget for defining range widget drawing range towers in arc form
/*!
The QRangeWidget_Bar class provides an easy approach to display ranges like signal strength, battery level etc in arc form. Inherits QRangeWidget\n\n
*/
class QRANGEWIDGETSHARED_EXPORT QRangeWidget_Arc:public QRangeWidget
{
	Q_OBJECT
public:
//! A constructor.
/*!
  Constructs a new QRangeWidget_Arc widget.

 \param x is an integer argument describing X position of range widget
 \param y is an integer argument describing Y position of range widget
 \param parent is a QWidget describing parent widget
*/
	QRangeWidget_Arc(int x, int y, QWidget *parent);


//! Destructor.
/*!
Destructor.
*/
	virtual ~QRangeWidget_Arc();

//! A derived member taking one argument and returning nothing
/*!
   This function used to implement drawing logic
  \param painter Argument specifying painter to be used for drawing arc ranges
*/
	void drawTowers(QPainter & painter);
};

#endif /*_QRANGEWIDGET_H_*/
